class Page{
    constructor(ops){
        this.box = ops.box;
        console.log(ops.box)
        this.list = ops.list;
        this.url = ops.url;
        this.num = ops.num || 20;
        this.index = ops.index || 0;
        this.load();
    }
    load(){
        $.ajax({
            url:this.url,
            data:{
                type:"getGoods"
            },
            success:res=>{
                console.log(res.msg)
                this.res = res.msg
                this.renderPage();
            },
            dataType:"json"
        })
    }
    renderPage(){
        this.box.pagination(this.res.length,{
            items_per_page: this.num,
            current_page: this.index,
            callback:(i)=>{
                console.log(i)
                this.index = i;
                this.render()
            }
        })
    }
    render(){
        console.log(this.index)
        console.log(this.res,this.index)
    }
}

new Page({
    box:$(".pagination"),
    list:$(".container").children(".cartshow"),
    url:"http://localhost:3000/api/",
    num:10,
    index:0
})